package com.leetcode.字符串;

import java.util.Scanner;
import java.util.TreeMap;

/**
 * @BelongsProject: LeetCode
 * @BelongsPackage: com.leetcode.字符串
 * @Author: lei
 * @CreateTime: 2024-03-11  15:00
 * @Description: TODO
 * @Version: 1.0
 */
public class DNA序列 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            int number = scanner.nextInt();
            if (line.length() < number) break;
            int result = 0;
            TreeMap<Integer, String> treeMap = new TreeMap<>();
            for (int i = 0; i < line.length(); i++) {
                // 每一个字段的文字
                String segment = line.substring(i, number + i);
                char[] chars = segment.toCharArray();
                int count = 0;
                // 统计每个字段中C与G的含量。考虑使用堆等其他结构处理
                for (int j = 0; j < chars.length; j++) {
                    String aChar = String.valueOf(chars[j]);
                    if (aChar.equals("C") || aChar.equals("G")) {
                        count++;
                    }
                }
                if (count > result) {
                    result = count;
                    treeMap.put(result, segment);
                }
                if (number + i == line.length()) break;
            }
            System.out.println(treeMap.lastEntry().getValue());
        }
    }
}
